First you load an ODF text document(for example),then get the meta file DOM and then use the meta DOM to create an instance of the Meta. Use Meta you can access all the supported elements.
The <meta:keyword> may contain many keywords, you can set the whole list of keywords and add one keyword as you want. the api currently do not provide the direct method for deleting one keyword ,you can get the keyword list first,and then delete the keyword,finally set the list to the element.
To manipulate the user defined data,you should get the list of their names,and then use the names to update the data or its datatype or delete the whole user defined data. you can use the setUserDefinedData(String name, String type, String value) method to update data,if the name not exists in the document,the method will add the new user defined data.
List<String> names=metadata.getUserDefinedDataNames(); for (String name : names) {
metadata.removeUserDefinedDataByName(name);
} String key="newId"; //org.odftoolkit.odfdom.dom.attribute.meta.MetaValueTypeAttribute.Value
metadata.setUserDefinedData(key, Value.STRING.toString(), "new001"); //update the datatype
metadata.setUserDefinedDataType(key, Value.BOOLEAN.toString()); //update the data value
metadata.setUserDefinedDataValue(key, "false");
//get the datatypeString dataType=metadata.getUserDefinedDataType(key); //get the data valueString dataValue=metadata.getUserDefinedDataValue(key);
if you want to access the document statistics,you should get a DocumentStatistic instance, if the return is null,it means that this ODF document doesn't have any document statistic information,you should create a document statistics object.
DocumentStatistic stat = metadata.getDocumentStatistic(); if(stat==null) {
stat=newDocumentStatistic(metadata.getOfficeMetaElement().newMetaDocumentStatisticElement());
}